/**
 * Created by Administrator on 2015/10/15.
 */
window.onload=function() {
    var url = getUrl();
    var userid=getUserId();
    //全部订单
    $.jsonp({
        url: 'http://'+url+'/api/order/order_list?state='+0,
        data: {userId:userid},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            var complied_tpl = juicer($("#order0_tpl").text());
            var html = complied_tpl.render(data);
            $("#allorder_1").html(html);
        },
        error: function (xOptions, textStatus) {}
    });
    $.jsonp({
        url: 'http://'+url+'/api/order/order_list?state='+1,
        data: {userId:userid},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            var complied_tpl = juicer($("#order1_tpl").text());
            var html = complied_tpl.render(data);
            $("#allorder_2").html(html);
        },
        error: function (xOptions, textStatus) {}
    });
    $.jsonp({
        url: 'http://'+url+'/api/order/order_list?state='+2,
        data: {userId:userid},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            var complied_tpl = juicer($("#order2_tpl").text());
            var html = complied_tpl.render(data);
            $("#allorder_3").html(html);
        },
        error: function (xOptions, textStatus) {}
    });
    $.jsonp({
        url: 'http://'+url+'/api/order/order_list?state='+3,
        data: {userId:userid},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            var complied_tpl = juicer($("#order3_tpl").text());
            var html = complied_tpl.render(data);
            $("#allorder_4").html(html);
        },
        error: function (xOptions, textStatus) {}
    });
    $.jsonp({
        url: 'http://'+url+'/api/order/order_list?state='+4,
        data: {userId:userid},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            var complied_tpl = juicer($("#order4_tpl").text());
            var html = complied_tpl.render(data);
            $("#allorder_5").html(html);
        },
        error: function (xOptions, textStatus) {}
    });
    //未付款
    $(document).on("click",".nopay",function(){
        $.jsonp({
            url: 'http://'+url+'/api/order/order_list?state='+0,
            data: {userId:userid},
            callbackParameter: "callback",
            success: function (data, textStatus, xOptions) {
                var complied_tpl = juicer($("#nopay_tpl").text());
                var html = complied_tpl.render(data);
                $(".ma_con02").html(html);
            },
            error: function (xOptions, textStatus) {}
        });
    });
    //已付款
    $(document).on("click",".pay",function(){
        $.jsonp({
            url: 'http://'+url+'/api/order/order_list?state='+1,
            data: {userId:userid},
            callbackParameter: "callback",
            success: function (data, textStatus, xOptions) {
                var complied_tpl = juicer($("#pay_tpl").text());
                var html = complied_tpl.render(data);
                $(".ma_con03_1").html(html);
            },
            error: function (xOptions, textStatus) {}
        });
        $.jsonp({
            url: 'http://'+url+'/api/order/order_list?state='+2,
            data: {userId:userid},
            callbackParameter: "callback",
            success: function (data, textStatus, xOptions) {
                var complied_tpl = juicer($("#pay_tpl").text());
                var html = complied_tpl.render(data);
                $(".ma_con03_2").html(html);
            },
            error: function (xOptions, textStatus) {}
        });
    });
    //待评价
    $(document).on("click",".noevaluate",function(){
        $.jsonp({
            url: 'http://'+url+'/api/order/order_list?state='+3,
            data: {userId:userid},
            callbackParameter: "callback",
            success: function (data, textStatus, xOptions) {
                var complied_tpl = juicer($("#noevaluate_tpl").text());
                var html = complied_tpl.render(data);
                $(".ma_con04").html(html);
            },
            error: function (xOptions, textStatus) {}
        });
    });
}
